package com.example.springbootlocal.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.springbootlocal.common.DBSql;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author X.I.O
 * @title: TestController
 * @projectName spring-boot-local
 * @description: TODO
 * @date 2021/11/9 14:04
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/test")
    public Map<String, Object> testController(){
        Map<String, Object> map=new HashMap<>();
        map.put("msg","success");
        return map;
    }

    @GetMapping("/testjdbc")
    public JSONObject testJDBCCOntroller(){
        Map<String, String> stringMap=new HashMap<>();
        stringMap.put("url","jdbc:mysql://127.0.0.1:3306/spring-demo?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull");
        stringMap.put("username","root");
        stringMap.put("password","admin");
        stringMap.put("driver","com.mysql.cj.jdbc.Driver");
        DBSql dbSql=new DBSql(stringMap);
        List<Map<String, Object>> obj=dbSql.selectMapObjList("select * from sys_user");
        System.out.println(obj);
        JSONObject ob=new JSONObject();
        ob.put("data",obj);
        return ob;
    }


}
